﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConceptionLogiciel_Devoir1
{
    class Client : Conducteur
    {
        protected int noCarteCredit;
        protected double solde;
        protected Dictionary<int, SessionLocation> mapLocation;

        // Constructor
        // -------------------------------------------------------------------------------
        public Client() { }
        public Client(int _noCarteCredit, double _solde) : base()
        {
            this.noCarteCredit = _noCarteCredit;
            this.solde = _solde;
            this.mapLocation = new Dictionary<int, SessionLocation>();
        }

        public Client(String _nom, String _prenom, String _noTelephone, String _adresse,
            String _noPermisConduire, int _noCarteCredit, double _solde) : base()
        {
            this.nom = _nom;
            this.prenom = _prenom;
            this.noTelephone = _noTelephone;
            this.adresse = _adresse;
            this.noPermisConduire = _noPermisConduire;
            this.noCarteCredit = _noCarteCredit;
            this.solde = _solde;
            this.mapLocation = new Dictionary<int, SessionLocation>();
        }

        public Client(String _nom, String _prenom, String _noTelephone, String _adresse,
            String _noPermisConduire, int _noCarteCredit, double _solde, DateTime _dateDebut, DateTime _dateFin) 
        {
            this.nom = _nom;
            this.prenom = _prenom;
            this.noTelephone = _noTelephone;
            this.adresse = _adresse;
            this.noPermisConduire = _noPermisConduire;
            this.noCarteCredit = _noCarteCredit;
            this.solde = _solde;
            this.mapLocation = new Dictionary<int, SessionLocation>();

            //this.mapLocation.Add();
            // creer une fonction qui parcours la liste des clients pour aller chercher le plus grand nodeLocation
        }

        // Getters && setters
        // -------------------------------------------------------------------------------
        public int NoCarteCredit
        {
            get { return noCarteCredit; }
            set { this.noCarteCredit = value; }
        }

        public double Solde
        {
            get { return solde; }
            set { this.solde = value; }
        }

        // Save the location 
        // -------------------------------------------------------------------------------
        public void ajouterLocation(int _noLocation, SessionLocation _sessionLocation)
        {
            mapLocation.Add(_noLocation, _sessionLocation);
        }

        // Location du client
        // -------------------------------------------------------------------------------
        public Dictionary<int, SessionLocation> getMapLocation()
        {
            return mapLocation;
        }

        // retourne la plus grande cle de location pour le client courant
        public int getBiggestLocationId()
        {
            int currId = -1;
            foreach (KeyValuePair<int, SessionLocation> loc in mapLocation)
            {
                if (loc.Key > currId)
                    currId = loc.Key;
            }

            return currId;
        }

        public override string ToString()
        {
            return this.nom + ", " + this.prenom;
        }

    }  // End class Client
}  // End namespace devoir3_conception_location
